﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using DataAccessLayer.Entity;
namespace DataAccessLayer.Adapter
{
    public class XaPhuongAdapter
    {
        clsKetNoiCSDL kn = new clsKetNoiCSDL();
       // DataTable dt;
        public DataTable LoadXaPhuong()
        {
            return kn.LoadDL("tbXaPhuongLoad");
        }
        public DataTable LoadTenXaPhuongByMaHuyen(clsXa_Phuong clsXaPhuong)
        {
            int N = 1;
            string[] name = new string[N];
            object[]value=new object[N];
            name[0] = "@MaHuyen"; value[0] = clsXaPhuong.MaHuyenThi;
            return kn.LoadDL("tbXaPhuong_SelectByMaQuanHuyen",name,value,N);
        }
        public void ThemXaPhuong(clsXa_Phuong clsXa)
        {
            int Npa=6;
            string sql="tbXaPhuongThem";
            string []name=new string[Npa];
            object[]value=new object[Npa];
            name[0] = "@MaXaPhuong"; value[0] = clsXa.MaXaPhuong;
            name[1] = "@TenXaPhuong"; value[1] = clsXa.TenXaPhuong;
            name[2] = "@MaKVUT"; value[2] = clsXa.MaKVUT;
           // name[3]="@MaKVUT2"; value[3]=clsXa.MaKVUT2;
            name[4] = "@MaHuyen"; value[4] = clsXa.MaHuyenThi;
            name[5] = "@Active"; value[5] = clsXa.Active;
            kn.UpdateDL(sql, name, value, Npa);
        }

        public void SuaXaPhuong(clsXa_Phuong clsXa)
        {
            int Npa = 4;
            string sql = "tbXa_PhuongSua";
            string[] name = new string[Npa];
            object[] value = new object[Npa];
            name[0] = "@MaXaPhuong"; value[0] = clsXa.MaXaPhuong;
            name[1] = "@TenXaPhuong"; value[1] = clsXa.TenXaPhuong;
            name[2] = "@MaKVUT"; value[2] = clsXa.MaKVUT;
           // name[3] = "@MaKVUT2"; value[3] = clsXa.MaKVUT2;
            name[3] = "@MaHuyen"; value[3] = clsXa.MaHuyenThi;
           // name[5] = "@Active"; value[5] = clsXa.Active;
            kn.UpdateDL(sql, name, value, Npa);
        }
        public void XoaXaPhuong(clsXa_Phuong clsXa)
        {
            int npa = 1;
            string sql = "tbXa_PhuongXoa";
            string []name=new string[npa];
            object[]value=new object[npa];
            name[0] = "@MaXaPhuong"; value[0] = clsXa.MaXaPhuong;
            kn.UpdateDL(sql,name,value,npa);
        }
    }
}
